/**
  ******************************************************************************
  * @file    Devices_LED.c
  * @author  AnshininTakaha
  * @version V1.0
  * @date		 2021/09/27
  * @brief   The File of LED Init & LEDs Flashing Rules & APIs
	* @copyright (c) 2017-2021 JZI. All rights reserved.
  ******************************************************************************
  */
/* Includes ------------------------------------------------------------------*/
#include "Devices_LED.h"

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/



/* Exported mention ----------------------------------------------------------*/
/* Lidar LEDs Tips Functions */
void LED_LID_InitBeginning(void);
void LED_LID_InitProcessing(void);
void LED_LID_InitFinishing(void);
void LED_LID_Erroring(void);
void BEEP_LID_BAT_Erroring(void);
void LED_LID_BattaryRemain(int Modeset);

void LED_REC_InitBeginning(void);
void LED_REC_InitProcessing(void);
void LED_REC_InitFinishing(void);
void LED_REC_BattaryRemain(int Modeset2);


/* Exported variables --------------------------------------------------------*/
/* LED using Function */
LED_Fuc LED_Function = LED_FucGroundInit;
#undef LED_FucGroundInit


/* Exported functions --------------------------------------------------------*/
/**
 * @brief [Lidar Board] Init Begining Tips
 * @Statement Flash 2 times with middle speed and beep.
 * @param  void.
 * @return void.
 */
void LED_LID_InitBeginning(void)
{
	/* Close all the modules first */
	LID_DATA_LED_SetOFF();
	LID_BEEP_SetOFF();
	LID_BAT1_LED_SetOFF();
	LID_BAT2_LED_SetOFF();
	LID_BAT3_LED_SetOFF();
	LID_BAT4_LED_SetOFF();
	
	for(int i=0;i<4;i++)
	{
		//Beep..
		LID_BEEP_SetToggle();
		HAL_Delay(50);
		//LEDs..
		LID_BAT1_LED_SetToggle();
		HAL_Delay(40);
		LID_BAT2_LED_SetToggle();
		HAL_Delay(40);
		LID_BAT3_LED_SetToggle();
		HAL_Delay(40);
		LID_BAT4_LED_SetToggle();
		HAL_Delay(40);
	}
	
}



/**
 * @brief [Lidar Board] Init Processing Tips
 * @Statement Running Lights with 1 row. 
 * @param  void.
 * @return void.
 */
void LED_LID_InitProcessing(void)
{
	for(int i=0;i<2;i++)
	{
		LID_BAT1_LED_SetToggle();
		HAL_Delay(50);
		LID_BAT2_LED_SetToggle();
		HAL_Delay(50);
		LID_BAT3_LED_SetToggle();
		HAL_Delay(50);
		LID_BAT4_LED_SetToggle();
		HAL_Delay(100);
		LID_BAT1_LED_SetToggle();
		HAL_Delay(50);
		LID_BAT2_LED_SetToggle();
		HAL_Delay(50);
		LID_BAT3_LED_SetToggle();
		HAL_Delay(50);
		LID_BAT4_LED_SetToggle();
		HAL_Delay(150);
	}
}



/**
 * @brief [Lidar Board] Finish Processing Tips
 * @Statement Flash light 8 times with high speed.
 * @param  void.
 * @return void.
 */
void LED_LID_InitFinishing(void)
{
	for(int i=0;i<17;i++)
	{
		HAL_Delay(50);
		LID_DATA_LED_SetToggle();
		LID_BAT1_LED_SetToggle();
		LID_BAT2_LED_SetToggle();
		LID_BAT3_LED_SetToggle();
		LID_BAT4_LED_SetToggle();
	}
}	



/**
 * @brief [Lidar Board] Error Tips
 * @Statement Flash light 3 times with middle speed.
 * @param  void.
 * @return void.
 */
void LED_LID_Erroring(void)
{
	//LID_BEEP_SetOFF();
	LID_DATA_LED_SetOFF();
	LID_BAT1_LED_SetOFF();
	LID_BAT2_LED_SetOFF();
	LID_BAT3_LED_SetOFF();
	LID_BAT4_LED_SetOFF();
	
	HAL_Delay(500);
	
	for(int i=0;i<6;i++)
	{
		HAL_Delay(50);
		LID_BAT1_LED_SetToggle();
		LID_BAT2_LED_SetToggle();
		LID_BAT3_LED_SetToggle();
		LID_BAT4_LED_SetToggle();
	}
}


/**
 * @brief [Lidar Board] Error Tips
 * @Statement 
 * @param  void.
 * @return void.
 */
void BEEP_LID_BAT_Erroring(void)
{
	//Beep..
	LID_BEEP_SetToggle();
}

/**
 * @brief [Lidar Board] Battary remain tips
 * @Statement Battary Set lights
 * @param  void.
 * @return void.
 */
void LED_LID_BattaryRemain(int Modeset)
{
	switch(Modeset)
		{
			case 0:
				LID_BAT1_LED_SetOFF();
				LID_BAT2_LED_SetOFF();
				LID_BAT3_LED_SetOFF();
				LID_BAT4_LED_SetOFF();
				break;
			
			case 1:
				LID_BAT1_LED_SetOFF();
				LID_BAT2_LED_SetOFF();
				LID_BAT3_LED_SetOFF();
				LID_BAT4_LED_SetON();
				break;
			
			case 2:
				LID_BAT1_LED_SetOFF();
				LID_BAT2_LED_SetOFF();
				LID_BAT3_LED_SetON();
				LID_BAT4_LED_SetON();
				break;
			
			case 3:
				LID_BAT1_LED_SetOFF();
				LID_BAT2_LED_SetON();
				LID_BAT3_LED_SetON();
				LID_BAT4_LED_SetON();
			break;
				
			case 4:
				LID_BAT1_LED_SetON();
				LID_BAT2_LED_SetON();
				LID_BAT3_LED_SetON();
				LID_BAT4_LED_SetON();
				break;
			
			default:
				break;
		}
}


/**
 * @brief [Receiver Board] Receiver Init Tips
 * @Statement Data & Battary Running Light x2.
 * @param  void.
 * @return void.
 */
void LED_REC_InitBeginning(void)
{
	/* Close all the modules first */
	REC_DATA_LED_SetOFF();
	REC_BAT1_LED_SetOFF();
	REC_BAT2_LED_SetOFF();
	REC_BAT3_LED_SetOFF();
	
	for(int i=0;i<4;i++)
	{
		//LEDs..
		REC_DATA_LED_SetToggle();
		HAL_Delay(40);
		REC_BAT1_LED_SetToggle();
		HAL_Delay(40);
		REC_BAT2_LED_SetToggle();
		HAL_Delay(40);
		REC_BAT3_LED_SetToggle();
		HAL_Delay(40);
	}
}



/**
 * @brief [Receiver Board] Receiver Init Processing Tips
 * @Statement Data & Battary Running Light x1.
 * @param  void.
 * @return void.
 */
void LED_REC_InitProcessing(void)
{
	for(int i=0;i<2;i++)
	{
		REC_DATA_LED_SetToggle();
		HAL_Delay(50);
		REC_BAT1_LED_SetToggle();
		HAL_Delay(50);
		REC_BAT2_LED_SetToggle();
		HAL_Delay(50);
		REC_BAT3_LED_SetToggle();
		HAL_Delay(100);
		
		REC_DATA_LED_SetToggle();
		HAL_Delay(50);
		REC_BAT1_LED_SetToggle();
		HAL_Delay(50);
		REC_BAT2_LED_SetToggle();
		HAL_Delay(50);
		REC_BAT3_LED_SetToggle();
		HAL_Delay(150);
	}
}



/**
 * @brief [Receiver Board] Receiver Init Finishing Tips
 * @Statement Data & Battary Flashing Light x8.
 * @param  void.
 * @return void.
 */
void LED_REC_InitFinishing(void)
{
	for(int i=0;i<17;i++)
	{
		HAL_Delay(50);
		REC_DATA_LED_SetToggle();
		REC_BAT1_LED_SetToggle();
		REC_BAT2_LED_SetToggle();
		REC_BAT3_LED_SetToggle();
	}
}

/**
 * @brief [Receiver Board] Battary remain tips
 * @Statement Battary Set lights
 * @param  void.
 * @return void.
 */
void LED_REC_BattaryRemain(int Modeset2)
{
	switch(Modeset2)
		{
			case 0:
				REC_BAT1_LED_SetOFF();
				REC_BAT2_LED_SetOFF();
				REC_BAT3_LED_SetOFF();
				break;
			
			case 1:
				REC_BAT1_LED_SetON();
				REC_BAT2_LED_SetOFF();
				REC_BAT3_LED_SetOFF();
				break;
			
			case 2:
				REC_BAT1_LED_SetON();
				REC_BAT2_LED_SetON();
				REC_BAT3_LED_SetOFF();
				break;
			
			case 3:
				REC_BAT1_LED_SetON();
				REC_BAT2_LED_SetON();
				REC_BAT3_LED_SetON();
			break;
			
			default:
				break;
		}
}

/* End -----------------------------------------------------------------------*/
